package com.slipper.system.employee.front;

import java.util.List;

import com.slipper.common.bo.Result;
import com.slipper.system.employee.service.EmployeeService;
import org.springframework.web.bind.annotation.RestController;

import com.slipper.common.util.ResultUtil;
import com.slipper.system.api.employee.bo.EmployeeBO;
import com.slipper.system.api.employee.service.IEmployeeSv;

import javax.annotation.Resource;

@RestController
public class EmployeeSv implements IEmployeeSv {
    @Resource
    private EmployeeService employeeService;

    @Override
    public Result<EmployeeBO> queryBy(EmployeeBO bo){
        return ResultUtil.successResult(employeeService.queryBy(bo));
    }

    @Override
    public Result<List<EmployeeBO>> queryList(EmployeeBO bo) {
        return ResultUtil.successResult(employeeService.queryList(bo));
    }

    @Override
    public Result<List<EmployeeBO>> queryListWithOrg(EmployeeBO bo) {
        return ResultUtil.successResult(employeeService.queryListWithOrg(bo));
    }

    @Override
    public Result<List<EmployeeBO>> queryPage(EmployeeBO bo) {
        return ResultUtil.successResult(this.employeeService.queryPage(bo));
    }

    @Override
    public Result<EmployeeBO> queryByLogin(EmployeeBO bo) {
        if (bo.getUsername() == null || "".equals(bo.getUsername())
                || bo.getPassword() == null || "".equals(bo.getPassword())) {
            return ResultUtil.failureResult("用户名或密码错误！");
        }

        return ResultUtil.successResult(this.employeeService.queryByLogin(bo));
    }

    @Override
    public Result<?> saveUserRole(EmployeeBO bo) {
        return ResultUtil.saveResult(this.employeeService.saveUserRole(bo));
    }

    @Override
    public Result<?> updatePassword(EmployeeBO bo) {
        return ResultUtil.saveResult(employeeService.updatePassword(bo));
    }


    @Override
    public Result<?> save(EmployeeBO bo) {
        return ResultUtil.saveResult(this.employeeService.save(bo));
    }

    @Override
    public Result<?> delete(EmployeeBO bo) {
        return ResultUtil.deleteResult(employeeService.delete(bo));
    }

    @Override
    public Result<List<EmployeeBO>> queryByIds(EmployeeBO bo) {
        return ResultUtil.successResult(employeeService.queryByIds(bo));
    }

    @Override
    public Result<?> updateOrganization(EmployeeBO employee) {
        return ResultUtil.saveResult(employeeService.updateOrganization(employee));
    }
}
